home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / PROGRAMM / PASCAL / 0391B.ZIP / SKLOAD.PAS < prev    next >
Pascal/Delphi Source File  |  1987-02-22  |  2KB  |  60 lines

  1. PROGRAM SKLoad;
  2.  
  3. {Program to determine whether or not SK is loaded.  Thanks to unknown author
  4. of ACTSK.PAS for preliminary work on this concept.  This program may be useful
  5. for terminate-stay-resident programs to make sure that your user loads your
  6. TSR before, not after, SideKick.  Any questions, consult Bob Tolz,
  7. 110 Greene St., NY, NY 10012.  Compuserve [70475,1071].  July 14, 1986}
  8.  
  9.  
  10.   FUNCTION SideKickIsLoaded : Boolean;
  11.  
  12.   CONST MaxVectors = 10;
  13.     {Number of interrupts taken over by SK}
  14.  
  15.   TYPE
  16.     skstr = ARRAY[1..2] OF Char;
  17.     {'SK' can be found at LabelOffset of SK's code segment.
  18.     This is not in a string form, so we need to use a
  19.     2-character array rather than a string of length 2}
  20.  
  21.     VectorArray = ARRAY[1..10] OF Byte;
  22.     {Array of all interrupts taken over by SK}
  23.  
  24.     skpointer = ^skstr;
  25.  
  26.   VAR found : Boolean;
  27.     SKcodeseg, i : Integer;
  28.     skptr : skpointer;
  29.     {pointer to location where 'SK' ought to be found}
  30.  
  31.   CONST vectors : vectorarray = ($08, $09, $10, $13, $16,
  32.                                  $1C, $21, $25, $26, $28);
  33.     {interrupt vectors taken over by SK.  Cycle through all of them
  34.     in case a resident program is loaded after SK and takes over one
  35.     or more of the interrupts, thereby masking SK's control of that
  36.     vector.}
  37.  
  38.     LabelOffset = $016C;
  39.     {offset from code segment where 'SK' should be found}
  40.  
  41.   BEGIN
  42.     i := 1;
  43.     found := False;
  44.     REPEAT
  45.       SKCodeSeg := MemW[0:vectors[i]*4+2];
  46.       {SK's code segment is found at memw[0:vectors[i]*4+2]}
  47.  
  48.       skptr := Ptr(SKCodeSeg, Labeloffset);
  49.       IF skptr^ = 'SK' THEN found := True;
  50.       i := i+1;
  51.     UNTIL found OR (i > maxvectors);
  52.     sidekickisloaded := found;
  53.   END;                        {Sidekickisloaded}
  54.  
  55.  
  56. BEGIN
  57.   IF sidekickisloaded THEN WriteLn('SK loaded')
  58.   ELSE WriteLn('SK not loaded');
  59. END.
  60.        {Sidekick